package com.knowvoyage.knowvoyageserver.controller;

import com.knowvoyage.knowvoyageserver.pojo.entity.Dialog;
import com.knowvoyage.knowvoyageserver.pojo.vo.Result;
import com.knowvoyage.knowvoyageserver.service.DialogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "会话管理", description = "会话的增删改查接口")
@RestController
@RequestMapping("/dialog")
@RequiredArgsConstructor
public class DialogController {

    private final DialogService dialogService;

    @Operation(summary = "创建对话")
    @PostMapping("insert")
    public Result<Boolean> insert(@RequestBody Dialog dialog) {
        return dialogService.insert(dialog);
    }

    @Operation(summary = "删除对话")
    @GetMapping("/delete")
    public Result<Boolean> delete(@RequestParam Long dialogId) {
        return dialogService.delete(dialogId);
    }

    @Operation(summary = "更新对话")
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody Dialog dialog) {
        return dialogService.update(dialog);
    }

    @Operation(summary = "根据ID查询对话")
    @GetMapping("/selectById")
    public Result<Dialog> selectById(@RequestParam Long dialogId) {
        return dialogService.selectById(dialogId);
    }

    @Operation(summary = "根据用户ID查询对话列表")
    @GetMapping("/selectByUserId")
    public Result<List<Dialog>> selectByUserId(@RequestParam Long userId) {
        return dialogService.selectByUserId(userId);
    }

    @Operation(summary = "查询所有对话")
    @GetMapping("/selectAll")
    public Result<List<Dialog>> selectAll() {
        return dialogService.selectAll();
    }
}
